package com.serwis.app.entities;
// default package
// Generated 2014-07-29 18:57:10 by Hibernate Tools 3.4.0.CR1

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="T_PRODUCT")
public class Product implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private int productId;
	private String name;
	private BigDecimal netPrice;
	private int disposalAmount;
	private Category category;
	private Deliverer deliverer;
	private String description;
	private Set<RetailOrderDetails> retailOrderDetails = new HashSet<RetailOrderDetails>(0);
	private Set<DelivererOrderDetails> delivererOrderDetails = new HashSet<DelivererOrderDetails>(0);
	private Set<InvoiceDetails> invoiceDetails = new HashSet<InvoiceDetails>(0);


	public Product() {
	}

	public Product(String name, BigDecimal netPrice, int disposalAmount, Category category) {
		this.name = name;
		this.netPrice = netPrice;
		this.disposalAmount = disposalAmount;
		this.category = category;
	}
	
	public Product(String name, BigDecimal netPrice, int disposalAmount, Category category, Deliverer deliverer) {
		this.name = name;
		this.netPrice = netPrice;
		this.disposalAmount = disposalAmount;
		this.category = category;
		this.deliverer = deliverer;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="PRODUCT_ID",unique = true, nullable = false)
	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	@Column(name="NAME", nullable=false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="NET_PRICE", nullable=false)
	public BigDecimal getNetPrice() {
		return netPrice;
	}

	public void setNetPrice(BigDecimal netPrice) {
		this.netPrice = netPrice;
	}

	@Column(name="DISPOSAL_AMOUNT", nullable=false)
	public int getDisposalAmount() {
		return disposalAmount;
	}

	public void setDisposalAmount(int disposalAmount) {
		this.disposalAmount = disposalAmount;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PRODUCT_CATEGORY_ID", nullable = false)
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PRODUCT_DELIVERER_ID", nullable = true)
	public Deliverer getDeliverer() {
		return deliverer;
	}

	public void setDeliverer(Deliverer deliverer) {
		this.deliverer = deliverer;
	}

	@Column(name="DESCRIPTION", nullable=true)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product", cascade = CascadeType.ALL)
	public Set<RetailOrderDetails> getRetailOrderDetails() {
		return retailOrderDetails;
	}

	public void setRetailOrderDetails(Set<RetailOrderDetails> retailOrderDetails) {
		this.retailOrderDetails = retailOrderDetails;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product", cascade = CascadeType.ALL)
	public Set<DelivererOrderDetails> getDelivererOrderDetails() {
		return delivererOrderDetails;
	}

	public void setDelivererOrderDetails(
			Set<DelivererOrderDetails> delivererOrderDetails) {
		this.delivererOrderDetails = delivererOrderDetails;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product", cascade = CascadeType.ALL)
	public Set<InvoiceDetails> getInvoiceDetails() {
		return invoiceDetails;
	}

	public void setInvoiceDetails(Set<InvoiceDetails> invoiceDetails) {
		this.invoiceDetails = invoiceDetails;
	}

	


}
